<template>
  <div id="app">
    <div class="top-navbar">
      <div @click="goBack" class="back-button"><i class="icon-back"></i></div>
      <div class="top-title">{{routerName}}</div>
    </div>
    <transition name="slide-left">
       <router-view/>
    </transition>
   
  </div>
</template>

<script>
export default {
  name: 'App',
  data(){
    return {
      title:"信用卡管理",
      routerName:'信用卡管理'
    }
  },
  methods:{
    goBack(){
      if(this.$route.meta.backNative){
        this.JSback();
      }else{
        this.$router ? this.$router.back() : this.JSback();
      }
    },
    JSback(){
      // IOS和android采用了不同的JS交互方式 这里区分
       var u = navigator.userAgent;
       var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
       if(!isAndroid){
         window.WebViewJavascriptBridge.callHandler('backClick', null, function (response) {
            showResponse(response);
        })
       }else{
         window.android.invokeMethod(1,[true]);
       }
    },
                             
  },
  watch: {
    '$route' (to, from) {
      // 对路由变化作出响应...
      this.routerName = to.meta.title || 'title';
    }
  }  
}
</script>

<style>
html{
  height:100%;
  width: 100%;
  box-sizing: border-box;
  background-color: #F5F5F5;
  margin: 0;
  padding: 0;
  font-family: PingFangSC-Regular;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body,#app{
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
  user-select: none;
}
#app{
  padding-top: 2.75rem;
}
.top-navbar{
  position: fixed;
  top: 0;
  left: 0;
  height: 2.75rem;
  width: 100%;
  border-bottom: 1px solid #ededed;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  padding: 0.25rem .5rem;
  background-color: #ffffff;
}
.icon-back{
    width: 0.6rem;
    height:  0.6rem;
    margin-top: -0.0625rem;
    border-style: solid;
    border-width: 0.0625rem 0.0625rem 0 0;
    border-color: #333;
    transform-origin: 75% 25%;
    transform: rotateZ(-135deg);
    transition: 100ms ease-in .1s;
    transition: 100ms ease-in .1s;
}
.back-button{
  height: 100%;
  width: 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
}
.top-title{
  flex-grow: 1;
  text-align: center;
  box-sizing: border-box;
  padding-right: 2rem;
}
.slide-left-enter,
 .slide-right-leave-active {
     opacity: 0;
    -webkit-transform: translate(100%, 0);
    transform: translate(100%, 0);
}

.slide-left-leave-active,
.slide-right-enter {
     opacity: 0;
    -webkit-transform: translate(-100%, 0);
    transform: translate(-100% 0);
}
.dialog-demo .weui-dialog{
  z-index: 1000 !important;
}
.dialog-demo .weui-mask{
  z-index: 999 !important;
}
</style>
